import {homeMethod} from '@/utils/models/index.js'
const crudMethod = new homeMethod();
import Footer from '@/components/footer-main'
export default {
  name: 'Home',
  components: { Footer},
  data() {
    return {
      articleLoad: false,
      articleData: [],
      articleBg: {
        backgroundImage: require('@/assets/images/companyNewsBg.png'),
        backgroundRepeat: 'no-repeat',
        backgroundPosition: 'center',
        backgroundSize: '100% 100%'
      },
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 8
      }
    }
  },
  created() {
    document.title = '朔悦科技'
    this.handleScroll()
    this.getArticles()
  },
  methods: {
    handleScroll() {
      // this.$refs.articleRef.scrollIntoView(false);
      // this.$refs.articleRef.scrollTo(0,0)
    },
    // 分页查询公司新闻
    getArticles () {
      let _this = this
      _this.articleLoad = true
      let params = {
        pageNum: 1,
        pageSize: 10
      }
      crudMethod.getArticleFindPage(_this.queryParams).then((res) => {
        _this.articleLoad = false
        let {msg, code, data} = res;
        _this.total = data.total
        data.rows.forEach(item => {
          item.articlePic = item.articlePic ? _this.baseURL + item.articlePic : ''
        })
        _this.articleData = data.rows
      })
    },
  }
}
